<?php

/*
 * Create by Indonesian Brain Solutions
 * E-mail : cs@mesinit.com
 * Programmer : sony@sonywibisono.com
 */
class TicketStatusTypes {
var $id;
var $status_name;
var $description;
var $alert_enabled;
var $client_reminder;
var $count_time;
var $auto_close;


    function open($id){
        global $db;
        $sql="select * from ticket_status_types where id=$id";
        $row=$db->fetch_row($sql);
        if (!empty($row)){
            extract($row);
            $this->status_name=$status_name;
            $this->description=$description;
            $this->alert_enabled=$alert_enabled;
            $this->client_reminder=$client_reminder;
            $this->count_time=$count_time;
            $this->auto_close=$auto_close;

        }
    }

    function openAll(){
        $sql="select * from ticket_status_types order by id asc";
        $result=$db->query($sql);
        return $db->fetch_array($result);
        
    }

    function insert(){
    global $db;
    $sql="insert into ticket_status_types values (null,'{$this->status_name}',
'{$this->description}','{$this->alert_enabled}','{$this->client_reminder}',
'{$this->count_time}','{$this->auto_close}')";
    $db->query($sql);
    return mysql_insert_id();
    }

    function update(){
        global $db;
        $sql="update ticket_status_types set status_name='{$this->status_name}',
description='{$this->description}',alert_enabled='{$this->alert_enabled}',
client_reminder='{$this->client_reminder}',count_time='{$this->count_time}',
auto_close='{$this->auto_close}' where id=".$this->id;
        $db->query($sql);
    }

    function delete(){
        global $db;
        $sql="delete from ticket_status_types where id=".$this->id;
        $db->query($sql);
    }

}
?>
